<?php
namespace app\api\controller;
use think\Controller;
use think\Request;
use think\File;

class Image extends Controller
{
    public function upload(){
        //获取文件信息
        $file = Request()->file('file');

        //$file = Request::instance()->file('file');tp5.1不需要instance();
        //给定一个目录
        $info = $file ->move('upload');

        if($info && $info->getPathname()){
                // //  '/'这是对应的public入口文件 然后拼接返回的路径.$info->getPathname()
            return show(1,'success','/'.$info->getPathname());
        }
        return show(0,'upload error');

    }
}